/*************************************************************************
	> File Name: memonto.h
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月02日 星期四 18时18分11秒
 ************************************************************************/

#include<iostream>
#include <string>

class Memento
{
public:
	Memento() = default;
	Memento(std::string s) : state(s) {}

	std::string getState()
	{
		return state;
	}

private:
	std::string state;
};

class Originator
{
public:
	Originator() = default;
	Originator(std::string s) : state(s) {}

	void setState(std::string s)
	{
		this->state = s;
	}

	std::string getState()
	{
		return state;
	}

	Memento createMemento()
	{
		return Memento(this->state);
	}

	void setMemento(Memento m)
	{
		this->state = m.getState();
	}

	void show()
	{
		std::cout << "State = " << state << std::endl;
	}

private:
	std::string state;
};

class Caretaker
{
public:
	Caretaker() = default;
	Caretaker(Memento m) : memento(m) {}

	void setMemento(Memento m)
	{
		memento = m;
	}

	Memento getMemento()
	{
		return memento;
	}

private:
	Memento memento;
};
